{include file="public/header" /}

<article class="page-container">
    <form action="" method="post" class="form form-horizontal" enctype="multipart/form-data" id="form-add">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">申请人代理商：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="" value="{$data.agent|default=''}" readonly
                       datatype="*" nullmsg="卡号不能为空">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">商户名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="" value="{$data.name|default=''}"   style="width: 100%"
                       datatype="*" nullmsg="商户名称不能为空">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">商户手机号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="" value="{$data.mobile|default=''}"   style="width: 100%"
                       datatype="*" nullmsg="商户手机号不能为空">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">商户行业：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="" value="{$data.industry_name|default=''}"   style="width: 100%"
                       datatype="*" nullmsg="商户行业不能为空">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">商户地址：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="" value="{$data.address|default=''}"   style="width: 100%"
                       datatype="*" nullmsg="商户地址不能为空">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">营业执照：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <img src="{$data.license_url}" width="60px" height="60px" onclick="viewImage('{$data.license_url}')"/>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">门店照：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <img src="{$data.img_url}" width="60px" height="60px" onclick="viewImage('{$data.img_url}')"/>
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">申请备注：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="" value="{$data.remark|default=''}"   style="width: 100%"
                        >
            </div>
        </div>

        {if $data.status == 0}
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">状态：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <select name="status" class="select">
                        <option value="1" {if $data.status == 1 }selected{/if}>审核通过</option>
                        <option value="2" {if $data.status == 2 }selected{/if}>审核拒绝</option>
                    </select>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">审核意见：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" placeholder="" value="{$data.mark|default=''}"  name="mark" style="width: 100%"
                           datatype="*" nullmsg="审核意见不能为空">
                </div>
            </div>
            <div class="row cl" style="width: 100%">
                <div style="width: 100%;text-align: center">
                    <input type="hidden" value="{$data.id|default=''}" name="id">
                    <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                </div>
            </div>
            {else/}
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-2">审核意见：</label>
                    <div class="formControls col-xs-8 col-sm-9">
                        <input type="text" class="input-text" placeholder="" value="{$data.mark|default=''}"  name="mark" style="width: 100%"
                               datatype="*" nullmsg="审核意见不能为空">
                    </div>
                </div>
                <div class="row cl">
                    <label class="form-label col-xs-4 col-sm-2">状态：</label>
                    <div class="formControls col-xs-8 col-sm-9">
                        <select  class="select">
                            <option value="1" {if $data.status == 1 }selected{/if}>审核通过</option>
                            <option value="2" {if $data.status == 2 }selected{/if}>审核被拒</option>
                        </select>
                    </div>
                </div>
        {/if}

    </form>
</article>

<!--我在这做了修改，给了一个name属性，方便后端接收值-->

{include file="public/footer" /}
<script type="text/javascript">
    function viewImage(url) {
        window.open(url,"_blank")
    }

</script>
<script>
    $("#form-add").validate({
        rules: {
            username: {
                required: true,
                maxlength: 50
            },
        },
        onkeyup: false,
        focusCleanup: true,
        success: "valid",
        submitHandler: function (form) {
            $(form).ajaxSubmit({
                success: function (data) {
                    console.log(data);
                    if (data.status == 'y') {
                        layer.msg("操作成功", {icon: 1, time: 1000, shade: [0.3, '#000']}, function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.location.reload();
                            parent.layer.close(index);
                        });
                    } else {
                        layer.msg(data.info, {icon: 2, time: 1000, shade: [0.3, '#000']});
                    }
                },
                error: function (error) {
                    layer.msg('系统发生了错误', {icon: 2, time: 3000, shade: [0.5, '#FF0000']});
                }
            });

        }
    });


</script>
